package io.wjc.bean;

import java.io.Serializable;
import java.util.Date;

/**
 * @author wangjc
 *
 */
public class AccessToken implements Serializable {
	/**
	 * 单位秒，有效期1小时
	 */
	private long expires;

	/**
	 * token值
	 */
	private String value;

	/**
	 * 过期时间点
	 */
	private Date expiration;

	public Date getExpiration() {
		return expiration;
	}

	public String getValue() {
		return value;
	}

	//注意：不能在构造方法中初始化expiration，因为redis每次序列化都会调用构造方法
	public AccessToken(String value, long expires, Date expiration){
		this.value = value;
		this.expires = expires;
		this.expiration = expiration;
	}

	public boolean isExpired() {
		return getExpiration() != null && getExpiration().before(new Date());
	}

}
